Skip to content

Initial phase of port - #2

Open
timj wants to merge 30 commits into
mainfrom
u/timj/initial-phase
Open

timj wants to merge 30 commits into
mainfrom
u/timj/initial-phase

Conversation

@timj

@timj timj commented Nov 13, 2026

Copy link
Copy Markdown
Member

No description provided.

timj and others added 30 commits November 12, 2026 09:43
Pin reference/starlink-ast to 3d3f255f, the commit the Rust port pins.
Add the test helpers ported from the Rust tests (CValues, OracleFile,
Deferred, Fixtures), tools/ExtractApi.java and the extracted jniast API
with the test that checks it, the CI workflow, README and LICENSE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
CasesToJson reads the C probe tables committed in the Rust repository
(tests/<x>_oracle/cases.rs) with RustLiteral and writes them as JSON
under src/test/resources/oracle; ProbeData reads them back. Convert
object_id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
AstException carries the 179 AST__ status constants generated from
ast_err.msg by tools/GenErrorCodes.java with the MESSGEN formula, plus
jniast's SAI__OK and SAI__ERROR. CFormat emulates C's printf for one int
or double argument, rounding the exact binary value as C does, and
FitsFormat ports fitschan.c's EncodeFloat and RoundFString via the Rust
port.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
AstObject provides jniast's string attribute access (set, getC and the
typed forms, test, clear), parsed as C's object.c parses it, with the
per-class getAttrib/setAttrib/testAttrib/clearAttrib hooks; the Object
attributes Class, ID, Ident, UseDefs, Nobject, ObjSize and RefCount;
copy() through Cloneable with a deepCopy hook; and tune. CScan ports
C's strtod and the sscanf conversions AST uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Add NativeNode, NativeReader, NativeWriter, NativeStream and
ChannelOptions (Rust serial/), ObjectRegistry, Channel (Rust channel/
with channel.c attributes) and KeyMap with its helpers (Rust keymap/
with keymap.c attributes). AstObject gains its loading constructor and
dump, and equals, hashCode, toString and show written through a Channel.
Translate the keymap, channel, native read/write, ident and object-ID
tests that run with these classes, and add MalformedNativeTest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Add the Mapping base class (counts, Invert held per object as in C,
TranForward/TranInverse, transform validation, tran1/tran2/tranN/tranP,
the NaN protocol, Report with a per-thread report stream, the
simplification flags and simplify() returning the Mapping itself),
UnitMap, ShiftMap and ZoomMap with their native dumps, and jniast's
resampling types, whose resample and rebin methods throw
UnsupportedOperationException.

Translate the Mapping tests of the Rust port, and the Channel, KeyMap,
Ident and object ID tests left over from Task 5 that need these classes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
WinMap, MatrixMap and PermMap follow C's storage (MatrixMap's compressed
full/diagonal/unit forms, PermMap's zero-based permutations with null
arrays), dumps and loaders. CmpMap shares its components as C's astClone
does, records each one's Invert value at construction and compensates in
Transform, and copies them in deepCopy; its dump writes InvA/InvB and the
components as they are, so C's shared-component dump shape needs no
emulation. Also palDmat (internal.pal.Dmat) for MatrixMap's inverse, the
astEQUAL helpers, the mapping_load probe data, and the Task 6 leftovers
for these classes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
C's astMAKE_SET1/astMAKE_CLEAR1 attributes raise AST__IMMUT when the
object's reference count exceeds 1. AstObject now carries a mark, set
where C takes a clone (CmpMap components, KeyMap object entries put and
read) and cleared on copy(); ZoomMap's Zoom refuses set and clear while
marked, and testzoommap.c Errors 9 and 11 are translated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Ports rate (with C's per-class Rate overrides and the numerical
estimate), linearApprox, tranGrid, mapBox, mapSplit (C's protected
astMapSplit with per-class MapSplit overrides, CmpMap's MapSplit0/1/2
over astMapList) and decompose, from Rust mappings/{rate,linear_approx,
tran_grid,map_box}.rs and C mapping.c, cmpmap.c and the class files.
Translates the Rust tests for them, converts the tran_grid, map_split,
rate and tran_definedness probe tables (RustLiteral now reads enum
variants and u64 values), and removes the temporary jniast exclusions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
TransformOracleTest ports the Rust transform-oracle checker: three gates
over the C oracles with the header tolerances, the overrides file, the
whole-turn wrap, the round trip and the .map/.simp equivalence check.
SerialisationCorpusTest round-trips every C native fixture, and
NativeRoundTripTest every loadable class with non-default attributes.
Fixtures that cannot pass yet are listed in deferred/{simplify,headers,
framesets,serialisation}.txt, written with -Dast.writeDeferred=true from
the classes ObjectRegistry cannot load.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Port every file of the Rust port's src/erfa/ and src/pal/ into
internal.erfa and internal.pal, one class per Rust file, with the
per-value functions running at every point of the slice functions
where Rust uses its vectorised kernels. Tests: ErfaTest, PalTest and
PalGoldenTest, which checks every PAL routine against the C values in
golden/erfa_pal_roots.tsv, bit for bit where no elementary function
other than sqrt is involved and within libm rounding elsewhere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Port Rust src/wcslib into internal.wcslib (projection families, Prj,
Trig, WcsProjection), with the slice entries running the per-value
bodies, and WcsMap and SphMap with C's attributes, dump, load, copy and
MapSplit. Add the golden projection values, the WcsMap/SphMap tests,
ProjectionDomainTest and the leftovers earlier tasks addressed to this
one, and rewrite the oracle-gate deferred lists. Codespell ignores the
projection code COO.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
cminpack's lmder1, lmder, lmpar, qrfac, qrsolv, enorm and dpmpar are
ported from C into internal.cminpack. PolyMap follows Rust's polymap.rs
with C's coefficient storage, attributes, Copy, Dump and loader, the
iterative inverse with its lintrunc cache, and the blocked bulk
evaluation in scalar form. PolyTran fits through cminpack as polymap.c
does (C's grid order, isotropic scaling and initial guess), so fitted
coefficients follow C.

PolyMap is registered, and the oracle gates' deferred lists rewritten:
20 simplify fixtures and 20 serialisation fixtures now pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
SlaMap and TimeMap from Rust mappings/{slamap,timemap}.rs and C
slamap.c/timemap.c: the conversions, add/timeAdd, Dump and load,
Copy, and TimeMap's analytic Rate. The palMappa cache is a ThreadLocal;
the Fairhead and Bretagnon series is a constant table class.
Tests translate test_slamap.rs, test_timemap.rs, test_time_map_oracle.rs
(probe data time_map.json) and the timemap.rs unit tests, and add the
SlaMap/TimeMap parts of the constructor-check, NaN and round-trip tests.
The oracle gates' deferred lists are rewritten: 86 simplify and 86
serialisation fixtures now pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Port every file of Rust src/units/ to package-private Units*.java,
following C unit.c where the Rust port differs: known units searched
most recent first, CmpTree with astEQUAL and C's swapped-product result,
pi and e as their own opcodes, ConStart through sscanf semantics,
case-sensitive function names, and parse errors reported as AST__BADUN
rather than giving no conversion. A conversion that needs a MathMap
throws UnsupportedOperationException.

UnitMapperTest checks all 70 C unit-mapper cases bit for bit; UnitsTest
translates the src/units unit tests and checks NormUnit against C.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Axis (axis.c) with its per-class methods (AxisFormat, AxisUnformat,
AxisDistance, AxisOffset, AxisNorm, AxisNormValues, AxisIn, AxisOverlay)
and attributes; Frame (frame.c) with C's string attribute layer
including axis-indexed names, the generic per-axis path and the
one-axis retry, Cartesian geometry, format/unformat, permAxes,
pickAxes through SubFrame and Overlay, NormPoints, ResolvePoints,
active units with NewUnit, the Frame-as-Mapping identity transform,
and dump/load. Per-axis behaviour is reached through getAxis (1-based,
honouring the permutation) as C reaches it through GetAxis.
AxisFormat ports ParseAxisFormat/AxisFormat over CFormat; DateTime
ports astReadDateTime and astFmtDecimalYr. Units.relabel gives NewUnit
the rewritten label without building a MathMap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
FrameSet keeps C's arrays of Frames, nodes, links, Invert values and
Mappings: addFrame (copies, merging a FrameSet by reversing links),
removeFrame and remapFrame with TidyNodes, getMapping through Span,
Base and Current with inversion, variants (get, test, clear, mirror,
set and add), integrity around set and clear, the FrameSet as a Frame
forwarding to its current Frame and as a Mapping from base to current,
dump and loader. astConvert, needed to restore integrity and to add or
select variants, is a seam on Frame until Frame matching is ported.

CmpMap replaces a FrameSet component by its base-to-current Mapping.
Translates test_frameset, test_frameset_repair, test_frameset_current
and the FrameSet parts of earlier tasks' tests; the oracle gates'
deferred lists are rewritten (20 fixture entries now pass).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
Port C's astMatch (with the subclass cast retry), Match, Cast,
FindFrame, Convert/ConvertX and MatchAxes/MatchAxesX from frame.c and
frameset.c, with Rust frames/find_frame.rs as the guide. Match, cast,
convertX and matchAxesX stay overridable per class, as C's virtual
functions are, and FrameSet overrides them with its searches through
its Frames. Frame.findFrame and Frame.convert are public; the
astConvert seam convertFrames now works, so FrameSet integrity,
addVariant and setVariant run.

Translate test_find_frame.rs, test_convert.rs, test_match_axes.rs and
test_overlay.rs as far as their Frames exist, the leftover FrameSet,
ActiveUnit, MinMaxAxes and UnitMapper tests, and convert the
match_axes and overlay probe tables.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
SkyAxis (skyaxis.c) and SkyFrame (skyframe.c) with package-private
SkyConvert (MakeSkyMapping, VerifyMSMAttrs, TestSlaUnit) and SkyLast
(CalcLAST with per-thread tables of computed LAST values). SkyFrame
reaches per-axis behaviour through getAxis and overrides what
skyframe.c overrides; Frame now formats and reads ObsLat/ObsLon as
text through a dms.2 SkyFrame. Translates the sky tests and the
SkyFrame leftovers of earlier tasks; deferred lists rewritten.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
TimeFrame from C timeframe.c with Rust frames/timeframe.rs: attributes
(TimeScale, AlignTimeScale, TimeOrigin, LTOffset, ClockLat/ClockLon),
dump and loader, System and TimeScale changes re-expressing the
TimeOrigin, default Label/Symbol/Title/Epoch/Unit, date Format and
Unformat, Match/SubFrame/Overlay with MakeTimeMapping and MakeMap, and
currentTime. Package-private TimeFrame.tdbConv is fitschan.c's TDBConv
for FitsChan's epoch handling. SkyLast now converts between TimeFrames
as skyframe.c CalcLAST does. Tests translate test_timeframe.rs,
test_time_convert.rs, test_time_epoch.rs, test_time_scale_set.rs, the
timeframe.rs unit tests and the TimeFrame parts of earlier tests;
serialisation/timeframe.ast now passes both oracle gates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
CmpFrame ports cmpframe.c: the components are shared (astClone) and
copied by copy(); it overrides the Frame virtuals C's CmpFrame
overrides (getAxis, primaryFrame, match with PartMatch and
ComponentMatch, subFrame, overlay, cast, matchAxesX, the geometry and
the per-axis and shared attributes), and its attribute strings follow
C, an axis-numbered name being read from the primary Frame. FrameSet
appends a Frame's axes to every Frame with AST__ALLFRAMES.

The CmpFrame tests and the CmpFrame parts left by earlier tasks are
translated; the oracle gates' deferred lists are rewritten.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
The FrameSet variant, integrity and lsst oracle tests, the attribute
oracle tests (show/tostring, test/clear, clear-on-set, class
attributes, system change, frame class attributes) and the
serialisation tests (frame load, Channel dump and read, section load,
full fixture dumps, the rest of test_serialisation.rs), with their
probe data. FixtureFullDumpOracleTest gates the Full = 1 dumps of
every native fixture against C, deferring those that need classes
outside this version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
BadInputTest passes AST__BAD and NaN through tran2 of the FrameSet
read from lsst.ast and of one instance of each in-scope Mapping class;
ThreadCopyTest transforms through per-thread copies of that FrameSet
and of an FK5-to-Galactic conversion in eight threads, comparing with
the single-threaded results.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
…, FitsWarnings and FitsChanOptions

FitsChan's card API (putFits, putCards, findFits, testFits, the setFits
overloads, delFits, retainFits, purgeWCS, the typed getters), its
attributes through the string interface, its source (the Iterator
constructor), sink and close(), SourceFile and SinkFile, FITSCHAN_OPTIONS,
and its dump and loader. The default Encoding (fitschan.c GetEncoding) is
ported as FitsGuessEncoding, since the dump and DefB1950 need it.
read() and write() throw UnsupportedOperationException.

Tests translate the card tests of test_fitschan.rs, the card cases of
test_fitschan_cursor_oracle.rs and test_fitschan_errors.rs, and the unit
tests of the ported Rust files; RustLiteral reads struct literals and
imported enum variants for the fitschanerrors probe table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
FitsChan.read dispatches on the Encoding as fitschan.c Read does: NATIVE
Objects are read through the Channel reader, NativeStream, from the data
items FitsNativeReader gives (a port of fitschan.c GetNextData), and the
cards used are removed; the FITS-WCS branch calls FitsWcsRead.read, a stub
for now, and other foreign encodings throw UnsupportedOperationException.
NativeStream takes its items from a DataSource, so the Channel and the
FitsChan share C's reader, with its warnings, Strict and Clean handling.
A FitsChan made with no Iterator now has no source, as in C.

Tests: FitsNativeReaderTest, FitsChanNativeKeywordTest,
FixtureReadWarningsOracleTest (with deferred/read-warnings.txt), the
NATIVE read cases of FitsChanCursorOracleTest, and
cd_matrix_from_a_source_leaves_end_of_file_as_c_does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
…ead, FitsWcsMatrix, FitsWcsCelestial, FitsEpoch, FitsDates, FitsFiducial and FitsNativePole

FitsChan.read now reads the FITS-WCS encoding as fitschan.c does: SpecTrans
translates non-standard keywords, the WcsFcRead sweep marks the WCS cards,
the keywords of each axis description are extracted into a FitsStore, and
WcsMapFrm, WcsCelestial and FsetFromStore make the FrameSet, the celestial
part an N-axis Mapping as in C. Warnings are written as ASTWARN cards and
returned by warnings(). Spectral axes need SpecFrame, -TAB axes with TabOK
set need LutMap and non-spectral -LOG axes need MathMap; each throws
UnsupportedOperationException naming the class. Where the Rust port differs
from C the port follows C, recorded in docs/rust-c-differences.md.

The headers gate loads every .head fixture through a FitsChan; the fixtures
still deferred have a measured reason (needs SpecFrame/MathMap, or an
encoding whose read is out of scope), and deferred/oracle-rows.txt excuses
four rows on the CAR seam that differ only through C's simplification.

Tests: the FITS-WCS read tests of the Rust port, unit tests of each module,
SipHeadersTest, MalformedHeaderTest, WcsconvTest with deferred/wcsconv.txt,
and the tests earlier tasks left waiting for the read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
A separate Maven project, bench/, times Mapping.tranP and the NaN
protocol on the 78 sections of the Rust ast-bench sets framesets and
bench whose fixtures load, at 1, 1,000, 100,000 and 1,000,000 points,
reporting nanoseconds per call and, through an AuxCounters counter,
per point. BenchCases reads the set files and oracles from the
reference submodules; BenchAccess opens the package-private
transformIntoNan to the benchmarks. Results for JDK 21 and JDK 27 and
the Rust port's own ast-bench timings are committed beside them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
JniastApiTest already lists exactly the 28 phase 1 classes, and no
deferred list holds an UNEXPLAINED line. The report covers what was
ported, the time taken, the problems found, wider tolerances, deferred
items, benchmarks and estimates for the later phases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
docs/reports holds dated reports, as in the Rust port. The rulings made
while executing the phase 1 plan move there from the git-ignored
execution ledger, and the report links to them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DidLSPfwbAELCxqtcAbPhR
@timj
timj force-pushed the u/timj/initial-phase branch from 5b5f6ab to 5673d6f Compare November 15, 2026 15:18
@timj
timj added this pull request to stack #4 November 15, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant